package itheima.com.Reader;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;

public class ObjectInputStream_ {

    public static void main(String[] args) throws IOException, ClassNotFoundException {
        String filePath = "D:\\一条小团团\\data.dar";
        ObjectInputStream ois = null;

            ois = new ObjectInputStream(new FileInputStream(filePath));

            System.out.println(ois.readInt());
            System.out.println(ois.readChar());
            System.out.println(ois.readBoolean());
            System.out.println(ois.readDouble());
            System.out.println(ois.readByte());
            System.out.println(ois.readUTF());


            Object object = ois.readObject();
            System.out.println(object);
            System.out.println(object.getClass());

            Dog dog = (Dog) object;
            System.out.println("姓名："+dog.getName()+"年龄:"+dog.getAge());

            Object object1 = ois.readObject();
            System.out.println(object1);
            System.out.println(object1.getClass());

            Dog dog11 = (Dog) object1;
            System.out.println("姓名："+dog11.getName()+"年龄:"+dog11.getAge());

            try {
                ois.close();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
//            System.out.println(ois.readUTF());


    }

}
